<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>prevent default</title>
	</head>
	<body>
		
		<form action="http://www.haosou.com">
			卡号:<input type="text" id="username"/>
			密码:<input type="password" id="pwd"/>
			<button>submit</button>
		</form>
		<script>
			
			document.querySelector('form').addEventListener('submit',function(e){
				var username = document.getAttribute("username");
				var pwd = document.getAttribute("pwd");
				if(!(username && username.startsWith("10"))){
					alert("账号开头是10开头！")
					e.preventDefault();
				}
				
			});
		</script>
	</body>
</html>